<title>消息详情</title>

<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-card-body LAY_message_detail" id="LAY_org_detail_view"></div>

    <script type="text/html" id="LAY_org_detail_tpl">
      <div class="LAY_wisdom_title">
        <h3 class="LAY_wisdom_title_line">基本信息</h3>
      </div>

      <div class="layui-row layui-col-space20">
        <div class="layui-col-md6">
          <label class="layui-form-label">机构名称</label>
          <div class="layui-input-block">{{d.orgName || ''}}</div>
        </div>
        <div class="layui-col-md6">
          <label class="layui-form-label">机构简称</label>
          <div class="layui-input-block">{{d.orgSimpleName || ''}}</div>
        </div>
        <div class="layui-col-md6">
          <label class="layui-form-label">上级机构名称</label>
          <div class="layui-input-block">{{d.parentOrgName || ''}}</div>
        </div>
        <div class="layui-col-md6">
          <label class="layui-form-label">机构类型</label>
          <div class="layui-input-block">{{d.orgCategoryDesc || ''}}</div>
        </div>
        <div class="layui-col-md6">
          <label class="layui-form-label">机构编码</label>
          <div class="layui-input-block">{{d.orgCode || ''}}</div>
        </div>
        <div class="layui-col-md6">
          <label class="layui-form-label">商户编码</label>
          <div class="layui-input-block">{{d.merchantCode || ''}}</div>
        </div>
        <div class="layui-col-md6">
          <label class="layui-form-label">联系电话</label>
          <div class="layui-input-block">{{d.mobile || ''}}</div>
        </div>
      </div>

      {{# if (d.orgCategory == 'TEAM') { }}
      <hr>

      <div class="LAY_wisdom_title">
        <h3 class="LAY_wisdom_title_line">代理人团队拓展信息</h3>
      </div>

      <div class="layui-row layui-col-space20">
        <div class="layui-col-md6">
          <label class="layui-form-label">邀请码</label>
          <div class="layui-input-block">{{d.invitationCode || ''}}</div>
        </div>
      </div>
      {{# } }}

      {{# if (d.orgCategory == 'CHANNEL') { }}
      <hr>

      <div class="LAY_wisdom_title">
        <h3 class="LAY_wisdom_title_line">渠道拓展信息</h3>
      </div>

      <div class="layui-row layui-col-space20">
        <div class="layui-col-md6">
          <label class="layui-form-label">开发模式</label>
          <div class="layui-input-block">{{d.developModeDesc || ''}}</div>
        </div>
      </div>
      {{# } }}

      <hr>
	  <!-- added by lyuyang -->
	  {{# if (d.orgCategory == 'BROKER_ORG') { }}
	  <div class="LAY_wisdom_title">
        <h3 class="LAY_wisdom_title_line">工商注册信息</h3>
      </div>
	  
	  <div class="layui-row layui-col-space20">
        <div class="layui-col-md6">
          <label class="layui-form-label">法人</label>
          <div class="layui-input-block">{{d.legalPerson || ''}}</div>
        </div>
        <div class="layui-col-md6">
          <label class="layui-form-label">法人手机号码</label>
          <div class="layui-input-block">{{d.legalPersonMobile || ''}}</div>
        </div>
        <div class="layui-col-md6">
          <label class="layui-form-label">法人证件号码</label>
          <div class="layui-input-block">{{d.legalPersonPaperNo || ''}}</div>
        </div>
        <div class="layui-col-md6">
          <label class="layui-form-label">统一社会信用代码</label>
          <div class="layui-input-block">{{d.unifiedSocialCreditCode || ''}}</div>
        </div>
      </div>
	  <hr>
	  {{# } }}
	  <!-- added by lyuyang -->

      <div class="LAY_wisdom_title">
        <h3 class="LAY_wisdom_title_line">结算账户信息</h3>
      </div>

      <div class="layui-row layui-col-space20">
        <div class="layui-col-md6">
          <label class="layui-form-label">是否独立核算</label>
          <div class="layui-input-block">{{d.independentAccountabilityDesc || ''}}</div>
        </div>
        {{# if (d.orgCategory != 'CHANNEL_SUB_ACC') { }}
        <div class="layui-col-md6">
          <label class="layui-form-label">账户类型</label>
          <div class="layui-input-block">{{d.accountCategoryDesc || ''}}</div>
        </div>
        {{# } }}
        {{# if (d.orgCategory == 'BROKER_ORG' || d.orgCategory == 'CHANNEL') { }}
        <div class="layui-col-md6">
          <label class="layui-form-label">开户行</label>
          <div class="layui-input-block">{{d.bankName || ''}}</div>
        </div>
        <div class="layui-col-md6">
          <label class="layui-form-label">账号</label>
          <div class="layui-input-block">{{d.accountNo || ''}}</div>
        </div>
        <div class="layui-col-md6">
          <label class="layui-form-label">账户名</label>
          <div class="layui-input-block">{{d.accountName || ''}}</div>
        </div>
        {{# } }}
        {{# if (d.orgCategory == 'TEAM') { }}
        <div class="layui-col-md6">
          <label class="layui-form-label">团队长手机号</label>
          <div class="layui-input-block">{{d.teamLeaderMobile || ''}}</div>
        </div>
        {{# } }}
      </div>

      {{# if (d.orgCategory == 'BROKER_ORG' || d.orgCategory == 'TEAM') { }}
      <hr>

      <div class="LAY_wisdom_title">
        <h3 class="LAY_wisdom_title_line">结佣账户信息</h3>
      </div>

      <div class="layui-row layui-col-space20">
        <div class="layui-col-md6">
          <label class="layui-form-label">是否独立结佣</label>
          <div class="layui-input-block">{{d.independentBrokerageSettlementDesc || '否'}}</div>
        </div>
        <div class="layui-col-md6">
          <label class="layui-form-label">支付方式</label>
          <div class="layui-input-block">{{d.brokeragePayWayDesc || '代付'}}</div>
        </div>
        <div class="layui-col-md6">
          <label class="layui-form-label">支付通道</label>
          <div class="layui-input-block">{{d.brokeragePayPassageDesc || '宝付'}}</div>
        </div>
        <div class="layui-col-md6">
          <label class="layui-form-label">商户号</label>
          <div class="layui-input-block">{{d.payPassageMerchantNo || '委托独立核算上级进行结佣'}}</div>
        </div>
      </div>
      {{# } }}

      <div class="LAY_message_detail_btn_group">
        <button class="layui-btn layui-btn-primary LAY_org_detail_btn_back">返回</button>
      </div>
    </script>
  </div>
</div>

<script>
  layui.use(['admin', 'element', 'laypage', 'laytpl', 'table'], function () {
    var $ = layui.$,
            admin = layui.admin,
            setter = layui.setter,
            view = layui.view,
            table = layui.table,
            laytpl = layui.laytpl,
            laypage = layui.laypage,
            element = layui.element,
            router = layui.router(),
            orgCode = router.search.orgCode,
            showUpdateBtn = router.search.showUpdateBtn;

    getDetail();

    function getDetail() {
      admin.req({
        url: setter.url + '/org/detail',
        type: 'GET',
        data: {
          orgCode: orgCode
        },
        done: function (res) {
          var data = res.data || {};
          data.showUpdateBtn = showUpdateBtn;

          renderData(data, function () {
            initEvents();
          });
        }
      });
    }

    function initEvents() {
      $('.LAY_org_detail_btn_back').off('click').on('click', function () {
        admin.events.back();
      });

      $('.LAY_org_detail_btn_modify').off('click').on('click', function () {
        layerShow(orgCode, 'modify');
      });
    }

    function renderData(data, callback) {
      var getTpl = $('#LAY_org_detail_tpl').html();

      if (!getTpl) {
        return;
      }

      laytpl(getTpl).render(data, function(html){
        $('#LAY_org_detail_view').html(html);

        if (typeof(callback) === 'function') {
          callback();
        }
      });
    }

    // 显示编辑页
    function layerShow(orgCode, status) {
      var index = layer.open({
        type: 2
        ,title: orgCode ? '修改机构' : '新增机构'
        ,area: ['80%', '680px']
        ,content: '#/organization/form/orgCode=' + orgCode + '/status=' + status
        ,btn: ['确定', '取消']
        ,yes: function(index, layero){
          var body = layer.getChildFrame('body', index);
          body.find('#LAY_org_form_submit').click();
          return false;
        }
      });
    }

    window.refresh = getDetail;

  });
</script>